package com.fupeng.huawei;

import java.util.Scanner;


public class Main {
	int a=0;
	protected int b = 1;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] str = sc.nextLine().split(" ");
		System.out.println(result(str));
	}

	public static int result(String[] str){
		String A="";
		String B="";
		if(str[0].length()>str[1].length()){
			A = str[1];
			B = str[0];
		}else {
			A = str[0];
			B = str[1];
		}
		
		for(int i=A.length();i>0;i--){
			int j=0;
			while(j+i<=A.length()){
				if(B.contains(A.subSequence(j, j+i)))
					return i;
			}
		}
		return 0;
	}
}
